package com.example.rk.mapper;

import com.example.rk.entity.Company;
import com.example.rk.entity.Job;
import com.example.rk.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;


@Mapper
@Component
public interface UserMapper {
    @Delete("delete from user where id=#{id}")
    void deleteById(int id);

    @Select("SELECT * FROM user where id=#{id}")
    User findByID(int id);
//    @Select("SELECT * FROM user where sid=#{id}")
//    void findBySearch1(int id);
//    @Select("SELECT * FROM user where cid=#{id}")
//    void findBySearch2(int id);
    @Update("update user set zt='3' where id=#{id}")
    void doEdit1(int id);
    @Update("update user set zt='2' where id=#{id}")
    void doEdit2(int id);
    int count(String code, int id);

    List<User> findBySearchWithPage(int id ,int cid,int sid,int type);
    @Insert("insert into user (cid,sid,zt,gsaname,xsname,position) values(#{cid},#{sid},'0',#{gsname},#{xsname},#{positin})")
    void create(User user);


   List<User> findBySearch1(String gsname, String position, int sid);

    List<User> findBySearch2(String xsname,String position, int cid);
    @Insert("insert into user (cid,sid,zt,gsname,xsname,position) values(#{cid},#{sid},'0',#{gsname},#{xsname},#{position})")
    void create1(User user);
    @Insert("insert into user (cid,sid,zt,gsname,xsname,position) values(#{cid},#{sid},'1',#{gsname},#{xsname},#{position})")
    void create2(User user);
    @Select("SELECT information FROM job where id=#{id}")
    String getinformation(int sid);
    @Select("SELECT position FROM job where id=#{id}")
    String getposition(int id);
    @Select("SELECT sid FROM job where id=#{id}")
    int getsid(int id);
    @Select("SELECT cid FROM company where id=#{id}")
    int getcid(int id);
    @Select("SELECT name FROM company where id=#{id}")
    String getname(int id);
    @Select("SELECT position FROM company where id=#{id}")
    String getposition2(int id);

    List<User> findBySearchxs(String gsname, String position, int sid, int zt);

    List<User> findBySearchgs(String xsname,String position, int cid, int zt);
    @Select("SELECT phone FROM admin where id=#{id}")
    String getgsphone(int id);
    @Select("SELECT phone FROM admin where id=#{id}")
    String getxsphone(int id);
}
